#!/usr/bin/env python
# -*- coding: utf-8 -*-

#
# This program is free software; you can redistribute it and/or modify  
# it under the terms of the GNU General Public License as published by  
# the Free Software Foundation; either version 2 of the License, or     
# (at your option) any later version.                                   
#                                                                         
# A copy of the license can be found in the license.txt file supplied   
# with this software or at: http://www.gnu.org/copyleft/gpl.html       
#


RC_OK = 200

RC_NOT_FOUND = 400
RC_TIMEOUT   = 401

RC_TABLE_NOT_FOUND         = 431
RC_CELL_NOT_FOUND          = 432
RC_WORKER_NOT_FOUND        = 433
RC_TABLET_SERVER_NOT_FOUND = 434
RC_CELL_ALREADY_EXISTS     = 435

RC_OUT_OF_CELL_INTERVAL = 471


RC_INTERNAL_ERROR = 500


class   Response(object) :
    def __init__(self, status_code=RC_OK, body=None) :
        self.status_code = status_code
        self.body = body
        self.error = None
        ## __init__()

    def isOk(self) :
        return self.status_code == RC_OK
        ## isOk()

    def __str__(self) :
        if self.isOk() :
            return 'RC=%d' % (self.status_code,)
        else :
            return 'RC=%d error="%s"' % (self.status_code,self.error)
        ## __str__()

    def errorTableAlreadyExists(self) :
        return self.status_code == RC_CELL_ALREADY_EXISTS
        ## errorTableAlreadyExists()

    def errorCellAlreadyExists(self) :
        return self.status_code == RC_CELL_ALREADY_EXISTS
        ## errorCellAlreadyExists()

    ## class Response()



